﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SharpKit.JavaScript;

namespace SharpKit.Onx
{
    /// <summary>
    /// Base class for all components
    /// </summary>
    [JsType(JsMode.Prototype, Export = false)]
    public abstract class Emitter
    {
        #region Actions (Methods)
        /// <summary>
        /// Adds a script listener for an event.
        /// </summary>
        /// <param name="event">the event to listen on</param>
        /// <param name="listener">the script listener (callback)</param>
        /// <returns>a handle to be used for removing the listener</returns>
        [JsMethod(Name="addListener")]
        public object AddListener(string @event, Action listener)
        { 
            return null; 
        }

        /// <summary>
        ///  This method atomically causes the list associated with the object to be emptied of all key/value pairs, if there are any. 
        ///  If there are none, then the method does nothing.
        /// </summary>
        [JsMethod(Name = "clear")]
        public void Clear()
        { }

        /// <summary>
        /// Emits a (@see ScriptSignal) with a custom data property. Mainly used within scripts for testing purposes.
        /// </summary>
        /// <param name="event">the event name to emit</param>
        /// <param name="data">the custom data property to associate with the signal</param>
        [JsMethod(Name = "emit")]
        public void Emit(string @event, ScriptSignal data)
        { }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [JsMethod(Name = "getClassName")]
        public string GetClassName()
        {
            return null;
        }

        /// <summary>
        /// Removes a script listener.
        /// Note: this is a shorter alias for removeListener.
        /// </summary>
        /// <param name="event">the event that the listener registered on.</param>
        /// <param name="listener">the script listener</param>
        [JsMethod(Name="off")]
        public void Off(string @event, Action listener)
        { }

        /// <summary>
        /// Registers a script listener for an event.
        /// Note: this is a shorter alias for addListener
        /// </summary>
        /// <param name="event"></param>
        /// <param name="listener"></param>
        [JsMethod(Name="on")]
        public void On(string @event, Action listener)
        { }

        /// <summary>
        /// Registers a script listener for an event, the listener will be called once
        /// </summary>
        /// <param name="event"></param>
        /// <param name="listener"></param>
        [JsMethod(Name = "once")]
        public void Once(string @event, Action listener)
        { }

        /// <summary>
        /// Removes the all the script listeners for a given event
        /// </summary>
        /// <param name="event"></param>
        [JsMethod(Name = "removeAllListeners")]
        public void RemoveAllListeners(string @event)
        { }

        /// <summary>
        /// Removes a script listener.
        /// </summary>
        /// <param name="event">the event that the listener registered on.</param>
        /// <param name="listener">the script listener</param>
        [JsMethod(Name = "removeListener")]
        public void RemoveListener(string @event, Action listener)
        { }

        #endregion
    }
}